package sk.ygor.raynor.client.json.basetype;

import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import sk.ygor.raynor.client.json.JSONSerializationException;

public class java_lang_String_JSONSerializer extends BaseTypeSerializer<String> {

    @Override
    protected String deserializeNonNullValue(JSONValue jsonValue) {
        if (jsonValue.isString() != null) {
            return jsonValue.isString().stringValue();
        }
        throw new JSONSerializationException("Cannot create String from: " + jsonValue);
    }

    @Override
    protected JSONValue serializeNonNullValue(String javaValue) {
        return new JSONString(javaValue);
    }

}
